#pragma once
#include <iostream>
#include <assert.h>

using namespace std;

class Date
{
public:
	Date(int year = 1, int month = 1, int day = 1);

	bool operator<(const Date& d);
	bool operator<=(const Date& d);
	bool operator>(const Date& d);
	bool operator>=(const Date& d);
	bool operator==(const Date& d);
	bool operator!=(const Date& d);

	Date(const Date& d);

	Date& operator+=(int day);
	Date operator+(int day);

	Date& operator-=(int day);
	Date operator-(int day);

	Date& operator++();
	Date operator++(int);

	Date& operator--();
	Date operator--(int);

	//d1 -d2
	int operator-(const Date& a);

	int operator+(const Date& a);

	void Print()
	{
		cout << _year << "-" << _month << "-" << _day << endl;
	}

	int GetMonthDay(int year, int month)
	{
		assert(month > 0 && month < 13);
		static int MonthDays[13] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
		if (month == 2 && ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0))
		{
			return 29;
		}

		return MonthDays[month];
	}

	friend ostream& operator<<(ostream& out, const Date& d);
	friend istream& operator>>(istream& in, Date& d);

private:
	int _year;
	int _month;
	int _day;
};